package com.card.setting;

import com.card.gift.GiftHelp;
import com.xiaoao.net.db.Entity;
import com.xiaoao.net.db.Key;
import com.xiaoao.net.db.mongo.MongodbManager;
import com.xiaoao.net.json.message.JsonMessage;
import com.xiaoao.net.utils.PubFunc;
import com.xiaoao.net.utils.json.GSONUtils;

/**   
 * @Description: TODO(用一句话描述该文件做什么) 
 * @author siyunlong  
 * @date 2016年8月16日 下午4:09:14 
 * @version V1.0   
 */
public class GameSetting {
	private static final GameSetting instance = new GameSetting();
	public static GameSetting getInstance() {
		return instance;
	}
	
	public static final String T_SETTING_DATA = "gamesetting";
	
	public String wxBuy = "youxi";
	public String wxDl	= "youxi";
	public String androidXiazai = "https://fir.im/5x6q";
	public String iosXiazai = "https://fir.im/5x6q";
	public int ExchangeScale = 10;//兑换比例 ！！新加
	public int DayRewardGold = 0;//每日可领取金币数 ！！新加
	public int[] ModeGolds = {1,2,3};//每局的金币数
	public int[] DdzModeGolds = {1,2};//每局的金币数
	public int[] PdkModeGolds = {1,2};//每局的金币数
	public int[] ZjhModeGolds = {1,2,3};//每局的金币数
	public int[] NnModeGolds = {1,2,3};//每局的金币数
	public String gongGao;//新加公告！！！
	public int shareGold1 = 1;  //分享到朋友圈的房卡
	public int shareGold2 = 0; //分享到好友圈的房卡
	public int initGold = 8;
	
	public int share1Gold = 3;//每次分享获得房卡数
	public int shareDayMaxGold = 6;//每天最多获取房卡数
	public transient String ShareUrl = "https://fir.im/5x6q";
	public int BinCard = 2;//绑定身份证
	
	public transient int minCode = 0;
	public transient int iosMinCode = 0;
	public transient int touristCode = 8;
	public transient static int SieveWaitSecond = 2;
	public transient static int HandOutTimeOutDisbandSecond = 540;
	public transient static int HandOutTimeOutSecond = 30;
	
	public transient static int BetTime = 10;
	public transient static int OpenPaiTime = 1;
	public transient static int ScoreCalTime = 23;
	public transient static int EndTime = 3;
	public transient static int TggZhuangLeaveTime = 60;
	
	public void init() {
		Entity entity = MongodbManager.getInstance().getEntityFromDB(new Key(T_SETTING_DATA, "wx"));
		if(entity != null) {
			this.wxBuy = PubFunc.toString(entity.getProperty("buy"));
			this.wxDl = PubFunc.toString(entity.getProperty("daili"));
			this.androidXiazai = PubFunc.toString(entity.getProperty("androidxz"));
			this.iosXiazai = PubFunc.toString(entity.getProperty("iosxz"));
			this.gongGao = PubFunc.toString(entity.getProperty("gongGao"));
			this.touristCode = PubFunc.parseInt(entity.getProperty("touristCode"));
			this.shareGold1 = PubFunc.parseInt(entity.getProperty("shareGold1"));
			this.shareGold2 = PubFunc.parseInt(entity.getProperty("shareGold2"));
			this.initGold = PubFunc.parseInt(entity.getProperty("initGold"));
			this.minCode = PubFunc.parseInt(entity.getProperty("minCode"));
			this.iosMinCode = PubFunc.parseInt(entity.getProperty("iosMinCode"));
			this.share1Gold = PubFunc.parseInt(entity.getProperty("share1Gold"));
			this.shareDayMaxGold = PubFunc.parseInt(entity.getProperty("shareDayMaxGold"));
			this.BinCard = PubFunc.parseInt(entity.getProperty("BinCard"));
			this.ModeGolds = GSONUtils.FromJSONString((String)entity.getProperty("MjModeGolds"), int[].class);
			this.DdzModeGolds = GSONUtils.FromJSONString((String)entity.getProperty("DdzModeGolds"), int[].class);
			this.PdkModeGolds = GSONUtils.FromJSONString((String)entity.getProperty("PdkModeGolds"), int[].class);
			this.ZjhModeGolds = GSONUtils.FromJSONString((String)entity.getProperty("ZjhModeGolds"), int[].class);
			this.NnModeGolds = GSONUtils.FromJSONString((String)entity.getProperty("NnModeGolds"), int[].class);
			
		}
	}
	
//	public void updateWx(String buy,String dl) {
//		this.wxBuy = buy;
//		this.wxDl = dl;
//		saveWx();
//	}
	
	public void saveWx() {
		Entity entity = new Entity(T_SETTING_DATA, "wx");
		entity.setProperty("buy", wxBuy);
		entity.setProperty("daili", wxDl);
		entity.setProperty("androidxz", androidXiazai);
		entity.setProperty("iosxz", iosXiazai);
		entity.setProperty("gongGao", gongGao);
		entity.setProperty("touristCode", touristCode);
		entity.setProperty("shareGold1", shareGold1);
		entity.setProperty("shareGold2", shareGold2);
		entity.setProperty("initGold", initGold);
		entity.setProperty("minCode", minCode);
		entity.setProperty("iosMinCode", iosMinCode);
		entity.setProperty("share1Gold", share1Gold);
		entity.setProperty("shareDayMaxGold", shareDayMaxGold);
		entity.setProperty("BinCard", BinCard);
		
		entity.setProperty("MjModeGolds", GSONUtils.ToJSONString(ModeGolds));
		entity.setProperty("DdzModeGolds", GSONUtils.ToJSONString(DdzModeGolds));
		entity.setProperty("PdkModeGolds", GSONUtils.ToJSONString(PdkModeGolds));
		entity.setProperty("ZjhModeGolds", GSONUtils.ToJSONString(ZjhModeGolds));
		entity.setProperty("NnModeGolds", GSONUtils.ToJSONString(NnModeGolds));
		MongodbManager.getInstance().saveOrUpdate(entity);
	}

	public String getWxBuy() {
		return wxBuy;
	}

	public void setWxBuy(String wxBuy) {
		this.wxBuy = wxBuy;
	}

	public String getWxDl() {
		return wxDl;
	}

	public void setWxDl(String wxDl) {
		this.wxDl = wxDl;
	}
	

	public String getAndroidXiazai() {
		return androidXiazai;
	}

	public void setAndroidXiazai(String androidXiazai) {
		this.androidXiazai = androidXiazai;
	}

	public String getIosXiazai() {
		return iosXiazai;
	}

	public void setIosXiazai(String iosXiazai) {
		this.iosXiazai = iosXiazai;
	}

	public int getExchangeScale() {
		return ExchangeScale;
	}
	public int getDayRewardGold() {
		return DayRewardGold;
	}
	
	public void setExchangeScale(int exchangeScale) {
		ExchangeScale = exchangeScale;
	}
	public void setDayRewardGold(int dayRewardGold) {
		DayRewardGold = dayRewardGold;
	}
	
	public void setGongGao(String gongGao) {
		this.gongGao = gongGao;
	}
	

	public String getGongGao() {
		return gongGao;
	}

	public int getTouristCode() {
		return touristCode;
	}

	public void setTouristCode(int touristCode) {
		this.touristCode = touristCode;
	}
	

	public int getShareGold1() {
		return shareGold1;
	}

	public void setShareGold1(int shareGold1) {
		this.shareGold1 = shareGold1;
	}

	public int getShareGold2() {
		return shareGold2;
	}

	public void setShareGold2(int shareGold2) {
		this.shareGold2 = shareGold2;
	}

	public int getInitGold() {
		return initGold;
	}

	public void setInitGold(int initGold) {
		this.initGold = initGold;
	}
	
	public int getMinCode() {
		return minCode;
	}

	public void setMinCode(int minCode) {
		this.minCode = minCode;
	}

	public int getIosMinCode() {
		return iosMinCode;
	}

	public void setIosMinCode(int iosMinCode) {
		this.iosMinCode = iosMinCode;
	}

	public int getShare1Gold() {
		return share1Gold;
	}

	public void setShare1Gold(int share1Gold) {
		this.share1Gold = share1Gold;
	}

	public int getShareDayMaxGold() {
		return shareDayMaxGold;
	}

	public void setShareDayMaxGold(int shareDayMaxGold) {
		this.shareDayMaxGold = shareDayMaxGold;
	}

	public String getShareUrl() {
		return ShareUrl;
	}

	public void setShareUrl(String shareUrl) {
		ShareUrl = shareUrl;
	}
	

	public int[] getMjModeGolds() {
		return ModeGolds;
	}

	public int[] getDdzModeGolds() {
		return DdzModeGolds;
	}
	
	public int[] getPdkModeGolds() {
		return PdkModeGolds;
	}

	public int[] getZjhModeGolds() {
		return ZjhModeGolds;
	}

	public int[] getNnModeGolds() {
		return NnModeGolds;
	}

	public int getBinCard() {
		return BinCard;
	}

	public void setBinCard(int binCard) {
		BinCard = binCard;
	}

	public void fillConfMsg(JsonMessage message) {
		message.addProperty("wxinfo", GameSetting.getInstance());
		message.addProperty("giftConf", GiftHelp.getInstance().getGiftResouce());
	}
}
